package Utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @author tieyi  2019/12/18 15:15
 * @version 1.0.0
 * */
public class PropertiesUtil {
    private static Properties properties;
    private static class LazyHolder{
        private static final PropertiesUtil INSTANCE = new PropertiesUtil();
    }
    private PropertiesUtil(){

    }

    public static final PropertiesUtil getInstance(){
        return LazyHolder.INSTANCE;
    }

    public String getValues(String property){
        properties = new Properties();
        InputStream is = this.getClass().getResourceAsStream("/Arguments.properties");
        String data = "";
        try {
            InputStreamReader inputStreamReader = new InputStreamReader(is, "UTF-8");
            properties.load(inputStreamReader);
            data= properties.getProperty(property);
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                is.close();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
        return data;
    }
}
